import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { SCrossGuildWarChooseGroup } from "../../../../../Message/Public/SCrossGuildWarChooseGroup";
import { CrossGuildWarUtil } from "../util/CrossGuildWarUtil";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ObjCreate } from "../../common/ObjCreate";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
//class CrossGuildWarChooseGroupRender
    
    export  class CrossGuildWarChooseGroupRender extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.clickEnterHandler);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (arg1 == null || String(arg1) == "undefined") 
            {
                return;
            }
            _data = arg1;
            var loc1=_data as SCrossGuildWarChooseGroup;
            this._txtId.text = loc1.groupId.toString();
            this._txtPlayerNum.text = "(" + loc1.guildIds.length.toString() + "/" + loc1.totalNum.toString() + ")";
            if (CrossGuildWarUtil.isMyGuildInList(loc1.guildIds)) 
            {
                this.filters = [FilterConst.itemChooseFilter];
            }
            else 
            {
                this.filters = [];
            }
            return;
        }

        /* internal  */clickEnterHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (_data == null) 
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossGuildWarChooseGroupReq, _data));
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._btn = ObjCreate.createGLoadedButton(ResFileConst.CrossGuildWarGropBgBtn, 5, 5, 105, 106, this);
            var loc1=GlobalStyle.textFormat6;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            loc1.size = 40;
            loc1.font = FontUtil.xingkaiName;
            loc1.bold = true;
            this._txtId = ObjCreate.createGTextField("", 0, 9, 108, 60, this, loc1);
            this._txtId.mouseEnabled = false;
            ObjCreate.createBitmap(ImagesConst.CrossGuildWar_War, 15, 61, this);
            loc1 = GlobalStyle.textFormat6.clone();
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._txtPlayerNum = ObjCreate.createGTextField("", 0, 81, 108, 20, this, loc1);
            this._txtPlayerNum.mouseEnabled = false;
            return;
        }

        /* internal */ /* var */_txtId: GTextFiled;

        /* internal */ /* var */_btn: GLoadedButton;

        /* internal */ /* var */_txtPlayerNum: GTextFiled;
    }
